package com.stm.basicData.service.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.stm.basicData.domain.KfToolsTestProject;
import com.stm.basicData.mapper.KfToolsTestProjectMapper;
import com.stm.basicData.service.KfToolsTestProjectService;
import com.stm.common.annotation.DataScope;
import com.stm.common.core.text.Convert;
import com.stm.common.exception.BusinessException;
import com.stm.common.utils.DateUtils;

/**
 * 
 * @Description 试验项目列表impl
 * @CreateTime 2019年4月4日 上午8:43:59
 * @CreateBy 林龙
 */
@Service
public class KfToolsTestProjectServiceImpl implements KfToolsTestProjectService
{
    @Autowired
    private KfToolsTestProjectMapper kfToolsTestProjectMapper;
    

    /**
     * 根据条件分页查询数据
     * 
     * @param KfToolsTestProject 信息
     * @return list集合信息
     */
    @Override
    @DataScope(tableAlias = "b2")
    public List<KfToolsTestProject> selectAllPageList(KfToolsTestProject kfToolsTestProject){
        return kfToolsTestProjectMapper.selectAllPageList(kfToolsTestProject);
    }

    /**
     * 根据id查询信息
     * 
     * @param id 
     * @return 对象信息
     */
    @Override
    public KfToolsTestProject selectByPrimaryKey(String id){
        return kfToolsTestProjectMapper.selectByPrimaryKey(id);
    }

    /**
     * 新增保存信息
     * 
     * @param KfToolsTestProject 试验项目信息
     * @return 结果
     */
    @Override
    @Transactional
    public int insertKfToolsTestProject(KfToolsTestProject kfToolsTestProject){
    	UUID uuid = UUID.randomUUID();
    	kfToolsTestProject.setId(uuid.toString());
    	kfToolsTestProject.setCreateDate(DateUtils.getNowDate());
    	return kfToolsTestProjectMapper.insertSelective(kfToolsTestProject);
    }

    /**
     * 修改保存信息
     * 
     * @param KfToolsTestProject 试验项目信息
     * @return 结果
     */
    @Override
    @Transactional
    public int updateKfToolsTestProject(KfToolsTestProject kfToolsTestProject){
    	return  kfToolsTestProjectMapper.updateByPrimaryKeySelective(kfToolsTestProject);
    }
    
    /**
     * 批量删除
     * 
     * @param ids
     * @throws Exception
     */
    @Override
    public int deleteKfToolsTestProjectByIds(String ids) throws BusinessException
    {
        String[] kfToolsTestProjectIds = Convert.toStringArray(ids);
        return kfToolsTestProjectMapper.deleteKfToolsTestProjectByIds(kfToolsTestProjectIds);
    }

	@Override
	public void deleteKfToolsTestProjectByOptionId(String optionId) throws Exception {
		kfToolsTestProjectMapper.deleteKfToolsTestProjectByOptionId(optionId);
		
	}

}
